package com.leyu.mall.service.goods.impl;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ResponseBody;

import com.leyu.mall.common.facade.IGoodsBaseFacade;
import com.leyu.mall.dao.goods.GoodsBaseMapper;
import com.leyu.mall.domain.goods.GoodsBase;
import com.leyu.mall.service.goods.IGoodsBaseService;

@Service
@Transactional(rollbackFor = Exception.class)
public class GoodsBaseServiceImpl implements IGoodsBaseService,IGoodsBaseFacade {

	@Resource(name = "goodsBaseMapper")
	private GoodsBaseMapper goodsBaseMapper;

	public GoodsBase getGoodsBaseById(Long entity_id) throws Exception {
		return goodsBaseMapper.getGoodsBaseById(entity_id);
	}

	public int save(GoodsBase entity) throws Exception {
		if (entity.getGoodsId() == null) {
			System.out.println("GoodsBaseServiceImpl:addGoodsBase()...");
			return goodsBaseMapper.addGoodsBase(entity);
		} else {
			System.out.println("GoodsBaseServiceImpl:updateByPrimaryKey()...");
			return goodsBaseMapper.updateByPrimaryKey(entity);
		}
	}
	public void deleteGoodsBase(Long id) throws Exception {
		goodsBaseMapper.deleteGoodsBase(id);
	}
	public List<GoodsBase> getAllGoodsBase() throws Exception {
		return goodsBaseMapper.getAllGoodsBase();

	}
	public List<GoodsBase> getNewGoodsList() throws Exception{
		return goodsBaseMapper.getNewGoodsList();
	}
	public List<GoodsBase> getHotGoodsList() throws Exception{
		return goodsBaseMapper.getHotGoodsList();
		
	}
	public List<GoodsBase> getPromotionGoodsList() throws Exception{
		return goodsBaseMapper.getPromotionGoodsList();
		
	}
	
	public List<GoodsBase> getGroupGoodsList() throws Exception{
		return goodsBaseMapper.getGroupGoodsList();
		
	}
	 public int getGoodsListByPageCount()throws Exception {
		 return   goodsBaseMapper.getGoodsListByPageCount();
	 }
	 public List<GoodsBase> getGoodsListByPage(GoodsBase pagebean) throws Exception {
		 return goodsBaseMapper.getGoodsListByPage(pagebean);
	 }
	 
	 @ResponseBody
	 public  List<GoodsBase> getContractGoodsList() throws Exception{
		 return this.goodsBaseMapper.getContractGoodsList();
	 }
}